<template>
    <div class="e-form">
        <div style="width: 100%" class="form">
            <el-form ref="form" :model="formData.transportContractSettle" label-width="200px">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="结算编号：">
                            <span>{{ formData.transportContractSettle.billNo }}</span>
                        </el-form-item>
                    </el-col>
                     <el-col :span="12">
                        <el-form-item label="结算日期：">
                            <el-date-picker
                                v-model="formData.transportContractSettle.billDate"
                                type="date"
                                placeholder="选择日期"
                                value-format="yyyy-MM-dd"
                                format="yyyy 年 MM 月 dd 日"
                                :clearable="false"
                            >
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="合同编号：">
                            <el-input v-model="formData.transportContractSettle.contractNo"  readonly>
                                <i slot="suffix" class="el-input__icon el-icon-document-copy" ></i>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="结算单位：">
                            <span>{{ formData.transportContractSettle.settleOrgName }}</span>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                       <el-form-item label="税率%：">
                            <span>{{ formData.transportContractSettle.taxRate }}</span>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                         <el-form-item label="税额（元）：">
                             <el-input v-model="formData.transportContractSettle.taxAmount">
                            </el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                 <el-row>
                    <el-col :span="12">
                        <el-form-item label="发票编号：">
                            <el-input v-model="formData.transportContractSettle.invoice"  readonly>
                                <i slot="suffix" class="el-input__icon el-icon-document-copy" ></i>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                         <el-form-item label="机构：">
                            <span>{{ formData.transportContractSettle.orgName }}</span>
                            &emsp;
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                         <el-form-item label="不含税金额（元）：">
                            <span>{{ formData.transportContractSettle.amountExcludingTax }}</span>
                            &emsp;
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                         <el-form-item label="税价合计（元）：">
                            <span>{{ formData.transportContractSettle.totalTaxPrice }}</span>
                            &emsp;
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                         <el-form-item label="累计结算金额：">
                            <span>{{ formData.transportContractSettle.cumulativeSettleAmount }}</span>
                            &emsp;
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="终期结算：">
                            <el-checkbox v-model="formData.transportContractSettle.finalSettlement"></el-checkbox>
                        </el-form-item>
                    </el-col>
                </el-row>
                 <el-row>
                    <el-col :span="12">
                        <el-form-item label="冲预付款：">
                            <el-checkbox v-model="formData.transportContractSettle.rushAdvanceCharge"></el-checkbox>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <!-- 勾选冲预付款后填写 -->
                         <el-form-item label="冲预付款金额（元）：">
                             <el-input v-model="formData.transportContractSettle.rushAdvanceChargePrice">
                            </el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                 <el-row>
                   <el-col :span="12">
                        <el-form-item label="币种：">
                            <el-select
                                v-model="formData.transportContractSettle.currencyId"
                                placeholder="请选择"
                            >
                                <el-option
                                    v-for="(
                                        item, index
                                    ) in currencyForm"
                                    :key="index"
                                    :label="item"
                                    :value="item"
                                >
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12" >
                        <el-form-item label="传输财务共享：">
                            <span>{{ share.find(x=>x.value === formData.transportContractSettle.share).label}}</span>
                            &emsp;
                        </el-form-item>
                    </el-col>
                </el-row>
                 <el-row>
                     <el-col :span="12">
                         <el-form-item label="本位币：">
                            <span>{{ formData.transportContractSettle.baseCurName }}</span>
                            &emsp;
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                         <el-form-item label="本位币汇率：">
                            <span>{{ formData.transportContractSettle.baseCurRate }}</span>
                            &emsp;
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <el-form-item  label="备注信息：">
                            <el-input type="textarea" v-model="formData.transportContractSettle.remarks" placeholder="请输入内容"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>
        <div class="buttons">
            <el-button
                type="primary"
                size="small"
                class="btn-blue"
                @click="preserve"
                >保存</el-button
            >
            <el-button size="small" @click="handleClose">取消</el-button>
        </div>
    </div>
</template>

<script>
import request from '@/api/equip/equipSettle.js'
import { mapState } from 'vuex'
export default {
    data () {
        return {
            formData: {
                //基础信息
                'transportContractSettle': {
                    'amountExcludingTax': 0,
                    'baseCurId': '',
                    'baseCurName': '',
                    'baseCurRate': 0,
                    'baseCurTotalPrice': 0,
                    'billDate': '',
                    'billId': '',
                    'billNo': '',
                    'contractId': '',
                    'contractNo': '',
                    'cumulativeSettleAmount': 0,
                    'currency': '',
                    'currencyId': '',
                    'evaluateGrade': '',
                    'finalSettlement': 0,
                    'founderId': '',
                    'founderName': '',
                    'invoice': 0,
                    'isRed': true,
                    'nullifyCreated': '',
                    'nullifyCreator': '',
                    'nullifyCreatorId': '',
                    'nullifyDesciption': '',
                    'nullifyReason': '',
                    'orgId': '',
                    'orgName': '',
                    'redState': '',
                    'remarks': '',
                    'rmbId': '',
                    'rmbName': '',
                    'rmbRate': 0,
                    'rmbSumTotalPrice': 0,
                    'rushAdvanceCharge': 0,
                    'rushAdvanceChargePrice': 0,
                    'settleOrgId': '',
                    'settleOrgName': '',
                    'share': '0',
                    'sourceId': '',
                    'sourceNumber': '',
                    'state': '0',
                    'taxAmount': 0,
                    'taxRate': 0,
                    'totalTaxPrice': 0,
                    'workId': ''
                },
            },
            planNumberVisible: false,
            oldState: [
                {
                    value: '0',
                    label: '合同'
                },
                {
                    value: '1',
                    label: '申请'
                }
            ], //源单类型
            share: [
                {
                    value: '0',
                    label: '未传'
                },
                {
                    value: '1',
                    label: '已传'
                }
            ], //财务共享状态
        }
    },
    components: {
    },
    computed: {
        ...mapState({
            userInfo: state => state.userInfo,
            currencyForm: state => state.contract.ctClassify.currencyForm//币种
        }),
        statusLable () {
            return param=> {
                const state =  this.$store.state.equip.equipData.state//传财务单据状态
                const obj = state.find(x=>x.value === param)
                return obj.label
            }
        },
    },
    created () {
    },
    mounted () {
        this.userId = localStorage.getItem('userId')
        this.userName = localStorage.getItem('userName')
        const date = new Date()
        this.formData.transportContractSettle.billDate = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
        this.formData.transportContractSettle.founderName = this.userName
        this.formData.transportContractSettle.founderId = this.userId
        this.formData.transportContractSettle.orgName = this.userInfo.orgInfo.orgName
        this.formData.transportContractSettle.orgId = this.userInfo.orgInfo.orgId
        this.getDicValue()
    },
    methods: {
        //获取当前使用的字典
        getDicValue () {
        },
        cellMouseEnter (row) {
            this.MouseEnterId = row.id
        },
        cellMouseLeave () {
            this.MouseEnterId = 0
        },
        //保存
        preserve () {
            request.contractSettleAdd(this.formData).then(()=>{
                this.clientPop('suc', '保存成功', ()=>{ this.$router.push('/maintenanceSettleList') })
            })
        },
        //取消
        handleClose () {
            this.$router.go(-1)
        },
        selectConfirm () {},
    }
}
</script>

<style lang="scss" scoped>
.form {
    margin-top: 10px;
}

.e-table {
    background: #fff;

    /* .top {
    .left {
      padding: 20px;
      padding-top: 0px;
    }
  } */
}

.upload {
    margin: 20px auto;
    display: flex;
    justify-content: center;
    text-align: center;
}

.upload-demo {
    display: flex;
    justify-content: center;
    align-items: center;
}
</style>
